﻿using System.Windows;
using Controles;
using PapeleraEduardo.Componentes;

namespace PapeleraEduardo
{
    /// <summary>
    /// Lógica de interacción para MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            contenedorPrincipal.AddHandler(EventControlesHelper.CancelarClickEvent, new RoutedEventHandler(cancelarClickHandler));
            contenedorPrincipal.AddHandler(EventControlesHelper.CargarFacturaClickEvent, new RoutedEventHandler(cargarFacturaClickHandler));
            contenedorPrincipal.AddHandler(EventControlesHelper.BuscarFacturaClickEvent, new RoutedEventHandler(buscarFacturaClickHandler));
        }

        private void buscarFacturaClickHandler(object sender, RoutedEventArgs e)
        {
            expanderAdministracion.Visibility = System.Windows.Visibility.Hidden;
            expanderDocumentos.Visibility = System.Windows.Visibility.Hidden;
            expanderReporte.Visibility = System.Windows.Visibility.Hidden;

            contenedorPrincipal.Visibility = System.Windows.Visibility.Visible;

            componenteBuscarDocumentos componente = new componenteBuscarDocumentos();
            contenedorPrincipal.Content = componente;
        }

        private void cargarFacturaClickHandler(object sender, RoutedEventArgs e)
        {
            expanderAdministracion.Visibility = System.Windows.Visibility.Hidden;
            expanderDocumentos.Visibility = System.Windows.Visibility.Hidden;
            expanderReporte.Visibility = System.Windows.Visibility.Hidden;

            contenedorPrincipal.Visibility = System.Windows.Visibility.Visible;

            componenteFacturacion componente = new componenteFacturacion();
            componente.idSeleccionado = int.Parse(e.OriginalSource.ToString());
            contenedorPrincipal.Content = componente;
        }

        private void cancelarClickHandler(object sender, RoutedEventArgs e)
        {
            expanderAdministracion.Visibility = System.Windows.Visibility.Visible;
            expanderDocumentos.Visibility = System.Windows.Visibility.Visible;
            expanderReporte.Visibility = System.Windows.Visibility.Visible;

            contenedorPrincipal.Visibility = System.Windows.Visibility.Hidden;
            contenedorPrincipal.Content = null;
        }

        private void btnFacturacion_Click(object sender, RoutedEventArgs e)
        {
            expanderAdministracion.Visibility = System.Windows.Visibility.Hidden;
            expanderDocumentos.Visibility = System.Windows.Visibility.Hidden;
            expanderReporte.Visibility = System.Windows.Visibility.Hidden;

            contenedorPrincipal.Visibility = System.Windows.Visibility.Visible;
            contenedorPrincipal.Content = new componenteFacturacion();
        }

        private void btnArticulo_Click(object sender, RoutedEventArgs e)
        {
            expanderAdministracion.Visibility = System.Windows.Visibility.Hidden;
            expanderDocumentos.Visibility = System.Windows.Visibility.Hidden;
            expanderReporte.Visibility = System.Windows.Visibility.Hidden;

            contenedorPrincipal.Visibility = System.Windows.Visibility.Visible;
            contenedorPrincipal.Content = new componenteArticulos();
        }

        private void btnRubro_Click(object sender, RoutedEventArgs e)
        {
            expanderAdministracion.Visibility = System.Windows.Visibility.Hidden;
            expanderDocumentos.Visibility = System.Windows.Visibility.Hidden;
            expanderReporte.Visibility = System.Windows.Visibility.Hidden;

            contenedorPrincipal.Visibility = System.Windows.Visibility.Visible;
            contenedorPrincipal.Content = new componenteRubros();
        }

        private void btnFacturacionBuscar_Click(object sender, RoutedEventArgs e)
        {
            expanderAdministracion.Visibility = System.Windows.Visibility.Hidden;
            expanderDocumentos.Visibility = System.Windows.Visibility.Hidden;
            expanderReporte.Visibility = System.Windows.Visibility.Hidden;

            contenedorPrincipal.Visibility = System.Windows.Visibility.Visible;
            contenedorPrincipal.Content = new componenteBuscarDocumentos();
        }

        private void btnCliente_Click(object sender, RoutedEventArgs e)
        {
            expanderAdministracion.Visibility = System.Windows.Visibility.Hidden;
            expanderDocumentos.Visibility = System.Windows.Visibility.Hidden;
            expanderReporte.Visibility = System.Windows.Visibility.Hidden;

            contenedorPrincipal.Visibility = System.Windows.Visibility.Visible;
            contenedorPrincipal.Content = new componenteClientes();
        }
    }
}
